/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package py.com.systven.view;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import py.com.systven.bean.Cliente;

/**
 *
 * @author Adrian
 */
public class ClienteEditView extends java.awt.Dialog {

    /**
     * Creates new form ClienteEditView
     */
    public ClienteEditView(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        jLabel1 = new javax.swing.JLabel();
        nombreTF = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        profesionTF = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        fechanacTF = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        empresaTF = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        telempresaTF = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        rucTF = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        rentaTF = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        referenciaTF = new javax.swing.JTextField();
        inicioTF = new javax.swing.JTextField();
        tipoTF = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        telreferenciaTF = new javax.swing.JTextField();
        emailTF = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setText("Nombre ");
        add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 30, -1, -1));

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.nomCliente}"), nombreTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(nombreTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 30, 240, -1));

        jLabel2.setText("Profesion");
        add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.profesionCliente}"), profesionTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        profesionTF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                profesionTFActionPerformed(evt);
            }
        });
        add(profesionTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 70, 240, -1));

        jLabel3.setText("Fecha de Nac. ");
        add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 110, -1, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.fchNacimiento}"), fechanacTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(fechanacTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 110, 220, -1));

        jLabel4.setText("Empresa");
        add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, -1, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.empresaCliente}"), empresaTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(empresaTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 150, 240, -1));

        jLabel5.setText("Telef. Empresa");
        add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 190, -1, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.telEmpresa}"), telempresaTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(telempresaTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 190, 210, -1));

        jLabel6.setText("Tipo de Cliente");
        add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 150, -1, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.rucCliente}"), rucTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(rucTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(390, 30, 200, -1));

        jLabel7.setText("Renta Cliente");
        add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 230, -1, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.rentaCliente}"), rentaTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(rentaTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 230, 210, -1));

        jLabel8.setText("RUC Cliente");
        add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 30, -1, -1));

        jLabel9.setText("Referencia");
        add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 70, -1, -1));

        jLabel10.setText("Fecha inicio cliente");
        add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 110, -1, 10));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.refCliente}"), referenciaTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(referenciaTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 70, 190, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.desdeCliente}"), inicioTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(inicioTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 110, 170, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.tipoCliente}"), tipoTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(tipoTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 150, 180, -1));

        jLabel11.setText("Telef. Referencia");
        add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 180, -1, -1));

        jLabel12.setText("Email");
        add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(320, 220, -1, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.telReferencia}"), telreferenciaTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(telreferenciaTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 180, 180, -1));

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${registroactual.email}"), emailTF, org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        add(emailTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 220, 220, -1));

        jButton1.setText("Confirmar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarnuevocliente(evt);
            }
        });
        add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 290, -1, -1));

        jButton2.setText("Cancelar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
                cancelarnuevocliente(evt);
            }
        });
        add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(370, 290, -1, -1));

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Closes the dialog
     */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        setVisible(false);
        dispose();
    }//GEN-LAST:event_closeDialog

    private void profesionTFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_profesionTFActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_profesionTFActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void guardarnuevocliente(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarnuevocliente
setConfirmarcliente(true);
setVisible(false);        // TODO add your handling code here:
    }//GEN-LAST:event_guardarnuevocliente

    private void cancelarnuevocliente(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarnuevocliente
setConfirmarcliente(false);
setVisible(false);        // TODO add your handling code here:
    }//GEN-LAST:event_cancelarnuevocliente

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ClienteEditView dialog = new ClienteEditView(new java.awt.Frame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    protected Cliente registroactual;

    /**
     * Get the value of registroactual
     *
     * @return the value of registroactual
     */
    public Cliente getRegistroactual() {
        return registroactual;
    }

    /**
     * Set the value of registroactual
     *
     * @param resgistroactual new value of registroactual
     */
    public void setRegistroactual(Cliente registroactual) {
        Cliente oldRecord = this.registroactual;
this.registroactual = registroactual;
propertyChangeSupport.firePropertyChange("registroactual", oldRecord, registroactual);
    }

    private transient final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);

    /**
     * Add PropertyChangeListener.
     *
     * @param listener
     */
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(listener);
    }

    /**
     * Remove PropertyChangeListener.
     *
     * @param listener
     */
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }

    protected boolean confirmarcliente;

    /**
     * Get the value of confirmarcliente
     *
     * @return the value of confirmarcliente
     */
    public boolean isConfirmarcliente() {
        return confirmarcliente;
    }

    /**
     * Set the value of confirmarcliente
     *
     * @param confirmarcliente new value of confirmarcliente
     */
    public void setConfirmarcliente(boolean confirmarcliente) {
        this.confirmarcliente = confirmarcliente;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField emailTF;
    private javax.swing.JTextField empresaTF;
    private javax.swing.JTextField fechanacTF;
    private javax.swing.JTextField inicioTF;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField nombreTF;
    private javax.swing.JTextField profesionTF;
    private javax.swing.JTextField referenciaTF;
    private javax.swing.JTextField rentaTF;
    private javax.swing.JTextField rucTF;
    private javax.swing.JTextField telempresaTF;
    private javax.swing.JTextField telreferenciaTF;
    private javax.swing.JTextField tipoTF;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables
}
